using System.Collections.Generic;
using System.Runtime.Serialization;
using UnityEngine;

namespace GMME
{
    [DataContract]
    public class PlayerPosition
    {
        // 右，对应x
        [DataMember(Name = "right")]
        public float Right
        {
            get;
            set;
        }

        // 上，对应y
        [DataMember(Name = "up")]
        public float Up
        {
            get;
            set;
        }

        // 前，对应z
        [DataMember(Name = "forward")]
        public float Forward
        {
            get;
            set;
        }

#if UNITY_ANDROID
        internal static PlayerPosition ConvertPlayerPosition(AndroidJavaObject javaObject)
        {
            PlayerPosition playerPosition = new PlayerPosition();
            if (javaObject != null)
            {
                float right = javaObject.Call<float>("getRight");
                playerPosition.Right = right;
                float up = javaObject.Call<float>("getUp");
                playerPosition.Up = up;
                float forward = javaObject.Call<float>("getForward");
                playerPosition.Forward = forward;
                Debug.LogFormat("Right={0}, Up={1}, Forward={2}", playerPosition.Right, playerPosition.Up, playerPosition.Forward);
            }
            return playerPosition;
        }
#endif
    }
}
